/*
 * 配合投资详情页使用的JS逻辑
 * 2016-8-26
 * zhangzhichao
 */
/**************判断是否勾选条款***************/
var ck_fir_item = document.querySelector(".ck_fir_item");
var ck_sec_item = document.querySelector(".ck_sec_item");
var ck_fir_item_img = document.querySelector(".ck_fir_item img");
var ck_sec_item_img = document.querySelector(".ck_sec_item img");
var fir_item_bol = true;
var sec_item_bol = true;
ck_fir_item.onclick = function(){
	fir_item_bol=!fir_item_bol;
	if(fir_item_bol){
		ck_fir_item_img.src = "img/account/inves_info/checkbox_btn_cli.png";
	}else{
		ck_fir_item_img.src = "img/account/inves_info/checkbox_btn_uncli.png";
	}
}
ck_sec_item.onclick = function(){
	sec_item_bol=!sec_item_bol;
	if(sec_item_bol){
		ck_sec_item_img.src = "img/account/inves_info/checkbox_btn_cli.png";
	}else{
		ck_sec_item_img.src = "img/account/inves_info/checkbox_btn_uncli.png";
	}
}

/***************点击进入下一页****************/
var next_btn = document.querySelector(".next_btn>div");
next_btn.onclick = function(){
	var fir_item= document.getElementById('fir_item').className;
	var sec_item=document.getElementById('sec_item').className;
	var thi_item=document.getElementById('thi_item').className;
	var for_item=document.getElementById('for_item').className;
	var alert_box = document.querySelector(".alert_box");
	var demand ="1";
	var longtime="0";
	var shorttime="0";
	var risk="0";
	var bol=false;
	/**************判断投资目的勾选了哪一项***************/
	if(fir_item!=""){
		demand ="1";
	}else{
		demand ="0";
	}
	if (sec_item!="") {
		longtime="1";
	} else{
		longtime="0";
	}
	if(thi_item!=""){
		shorttime="1";
	}else{
		shorttime="0";
	}
	if(for_item!=""){
		risk="1";
	}else{
		risk="0";
	}
	/**************计算投资年限是否大于4年****************/
	var sum = parseInt(securityIdDom.value)+parseInt(forexIdDom.value)+parseInt(qihuoIdDom.value)+parseInt(qizhiIdDom.value)+parseInt(qiquanIdDom.value)+parseInt(goodsIdDom.value)+parseInt(propertyIdDom.value);
	if(sum>4){
		bol=true;
	}else{
		bol=false;
	}
	/*****************判断是否完成选项并跳转到下一页面******************/
	if(bol&&fir_item_bol==true&&sec_item_bol==true){
		window.location.href = "comp";
	}else if(bol==false){
		document.querySelector(".alert_txt>span").innerHTML = "投资年限之和要大于4年";
		location.href = "#";
		alert_box.style.display = "block";
	}else{
		document.querySelector(".alert_txt>span").innerHTML = "请您勾选同意以下条款";
		alert_box.style.display = "block";
	}
	/*************关闭弹窗***************/
	var alert_close = document.querySelector(".alert_close");
	alert_close.onclick=function(){
			document.querySelector(".alert_box").style.display="none";
	}
}
/**************投资目的选项**************/
$(function() {
	$('label').click(function() {
		$(this).toggleClass("checked");
	});
});


   